package cn.highedu.consumer.demos;

import cn.highedu.demo.service.DubboDemoService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.slf4j.Logger;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class DemoController {

    Logger logger = org.slf4j.LoggerFactory.getLogger(DemoController.class);

    // 通过DubboReference注解引用远程服务
    @DubboReference
    private DubboDemoService demoService;

    // 通过调用远程服务，获取服务提供方的响应
    @GetMapping("/hello/{name}")
    public String hello(@PathVariable String name) {
        logger.info("Hello, " + name + " from Service Consumer!");
        return demoService.hello(name) + " from Service Consumer!";
    }
}
